package organizer;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
 * Represents a set of files that have the exact same content.
 * @author dawong
 */
public class Duplicate {

    private Set<String> files;
    private String checksum;

    public Duplicate(String checksum) {
        this.checksum = checksum;
        files = new HashSet<String>();
    }

    public String getChecksum() {
        return checksum;
    }

    public Set<String> getFiles() {
        return Collections.unmodifiableSet(files);
    }

    public void add(String file) {
        files.add(file);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Duplicate other = (Duplicate) obj;
        if ((this.files == null) ? (other.files != null) : !this.files.equals(other.files)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + (this.files != null ? this.files.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "Duplicate{" + "files=" + files + '}';
    }

}
